package com.njtcedu.microblog.common.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@Table(name = "user_info", schema = "microblog")
public class UserInfo implements Serializable{

	@Id
	@GeneratedValue
	@Column(name = "id")
	private Integer id;

	@ManyToOne(cascade = CascadeType.REFRESH, optional = false)
	@JoinColumn(name = "user_id", nullable = false)
	private User user;
	
	@Column(name = "nick_Name", length = 30, nullable =false)
	private String nickName;

	@Column(name = "user_image", length = 100, nullable =true)
	private String userImage;
	
	@Column(name = "email", length = 50, nullable =true)
	private String email;

	@Column(name = "province", length = 50, nullable =true)
	private String province;
	
	@Column(name = "city", length = 50, nullable =true)
	private String city;
	
	@Column(name = "counties", length = 50, nullable =true)
	private String counties;
	
	@Column(name = "signup_date",  nullable =false)
	@Temporal(TemporalType.TIMESTAMP)
	private Date signupDate;//注册时间
	
	@Column(name = "gender", length = 50, nullable =true)
	private String gender;
	
	@Column(name = "description", length = 50, nullable =true)
	private String description;
	
	@Column(name = "content_count", length = 11, nullable =true)
	private Integer contentCount;
	
	@Column(name = "follow_count", length = 11, nullable =true)
	private Integer followCount;
	
	@Column(name = "followed_count", length = 11, nullable =true)
	private Integer followedCount;
	
	@Column(name = "last_login_date",  nullable =true)
	@Temporal(TemporalType.TIMESTAMP)
	private Date lastLoginDate;
	
	@Column(name = "last_sendcontent_date",  nullable =true)
	@Temporal(TemporalType.TIMESTAMP)
	private Date lastSendContentDate;//最后发表微博时间
	
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getNickName() {
		return nickName;
	}

	public void setNickName(String nickName) {
		this.nickName = nickName;
	}

	public String getUserImage() {
		return userImage;
	}

	public void setUserImage(String userImage) {
		this.userImage = userImage;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getProvince() {
		return province;
	}

	public void setProvince(String province) {
		this.province = province;
	}

	public Date getSignupDate() {
		return signupDate;
	}

	public void setSignupDate(Date signupDate) {
		this.signupDate = signupDate;
	}


	public String getGender() {
		return gender;
	}

	public void setGender(String gender) {
		this.gender = gender;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Integer getContentCount() {
		return contentCount;
	}

	public void setContentCount(Integer contentCount) {
		this.contentCount = contentCount;
	}

	public Integer getFollowCount() {
		return followCount;
	}

	public void setFollowCount(Integer followCount) {
		this.followCount = followCount;
	}

	public Integer getFollowedCount() {
		return followedCount;
	}

	public void setFollowedCount(Integer followedCount) {
		this.followedCount = followedCount;
	}

	public Date getLastLoginDate() {
		return lastLoginDate;
	}

	public void setLastLoginDate(Date lastLoginDate) {
		this.lastLoginDate = lastLoginDate;
	}

	public Date getLastSendContentDate() {
		return lastSendContentDate;
	}

	public void setLastSendContentDate(Date lastSendContentDate) {
		this.lastSendContentDate = lastSendContentDate;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public String getCity() {
		return city;
	}
	
	public void setCity(String city) {
		this.city = city;
	}

	public String getCounties() {
		return counties;
	}

	public void setCounties(String counties) {
		this.counties = counties;
	}

	@Override
	public int hashCode() {
		return id != null ? id.hashCode() : 0;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null || getClass() != obj.getClass())
			return false;
		UserInfo userInfo = (UserInfo) obj;
		return id != null ? id.equals(userInfo ) : userInfo .id == null;
	}

	@Override
	public String toString() {
		return "UserInfo [id=" + id + ", user=" + user + ", nickName=" + nickName + "]";
	}
}
